package com.tuozixuan;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.dtflys.forest.Forest;

import cn.dev33.satoken.sso.SaSsoManager;
import cn.dev33.satoken.sso.config.SaSsoClientConfig;

/**
 * SSO模式一，Client端 Demo 
 */
@SpringBootApplication
public class SaSso3ClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(SaSso3ClientApplication.class, args);
        
        System.out.println();
        System.out.println("---------------------- Sa-Token SSO 模式三 Client 端启动成功 ----------------------");
        System.out.println("配置信息：" + SaSsoManager.getClientConfig());
        System.out.println("测试访问应用端一: http://sa-sso-client1.com:9001");
        System.out.println("测试访问应用端二: http://sa-sso-client2.com:9001");
        System.out.println("测试访问应用端三: http://sa-sso-client3.com:9001");
        System.out.println("测试前需要根据官网文档修改hosts文件，测试账号密码：sa / 123456");
        System.out.println();
    }
    
 // 配置SSO相关参数
    @Autowired
    private void configSso(SaSsoClientConfig ssoClient) {
        // 配置Http请求处理器
        ssoClient.sendHttp = url -> {
            System.out.println("------ 发起请求：" + url);
            String resStr = Forest.get(url).executeAsString();
            System.out.println("------ 请求结果：" + resStr);
            return resStr;
        };
    }
}
